package com.shw.loco.adapter;

import android.app.Activity;
import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

/**
 * 
 * @author HAHA
 * 
 */
public class LocoMainService extends Service {

	private static final String TAG = "LocoMainService";
	private IBinder binder = new LocoMainService.SHWMainBinder();

	@Override
	public IBinder onBind(Intent arg0) {
		return binder;
	}

	@Override
	public void onCreate() {
		SharedPreferences sharedPreferences = getSharedPreferences("loco",
				Activity.MODE_PRIVATE);
		LocoMainTrigger lmt = new LocoMainTrigger(sharedPreferences);
		lmt.startRS485RFID();
		LocoNetManager lnm = new LocoNetManager(this,sharedPreferences);
		lnm.startSendRevThread();
		LocoCalRFIDThread calRFIDThread=new LocoCalRFIDThread(this,sharedPreferences);
		calRFIDThread.start();
//		TestThread testThread=new TestThread();
//		testThread.start();
//		TestGPSThread gpstestThread=new TestGPSThread();
//		gpstestThread.start();
//		TestSourceThread testSourceThread=new TestSourceThread();
//		testSourceThread.start();
	}

	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		return START_STICKY;
	}

	@Override
	public void onDestroy() {
		Log.d(TAG, "The service is stop");
	}

	public class SHWMainBinder extends Binder {
		LocoMainService getService() {
			return LocoMainService.this;
		}
	}

}
